/*
 * Pizza.java
 *
 * Created on 30 octobre 2007, 16:47
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.ifips5.nal.epizza.web.model;

import com.ifips5.nal.epizza.web.IngredientManager;
import java.util.LinkedList;
import java.util.List;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@XmlRootElement(name = "pizza")
public class Pizza implements Serializable
{
    @XmlElement(name = "ingredient")
    @XmlIDREF
    private List<Ingredient> ingredients = new LinkedList();
    
    @XmlAttribute(name = "id")
    private int idPizza;
    
    @XmlAttribute(name = "name")
    @XmlID
    private String name;
    
    
    @XmlAttribute(name = "vegetarian")
    private boolean vegetarienne;
    
    private boolean perso;
    
    @XmlAttribute(name = "price")
    private double prix;
    
  
    public Pizza()
    {
    }
    
    /** Creates a new instance of Pizza */
    public Pizza(int id, String name, boolean vege, boolean perso, double prix)
    {
        this.setIdPizza(id);
        this.setName(name);
        this.setVegetarienne(vege);
        this.setPerso(perso);
        this.setPrix(prix);
    }

    public void addIngredient(Ingredient ingredient)
    {
        this.getIngredients().add(ingredient);
    }
    
    
    public boolean containIngredient(Ingredient ingredient)
    {
        if(this.ingredients.contains(ingredient))
            return true;
        return false;
    }

    
    
    //////////////////////
    // Getters and Setters 

    public List<Ingredient> getIngredients()
    {
        return ingredients;
    }

    @XmlTransient
    public void setIngredients(List<Ingredient> ingredients)
    {
        this.ingredients = ingredients;
    }

    @XmlTransient
    public int getIdPizza()
    {
        return idPizza;
    }

    public void setIdPizza(int idPizza)
    {
        this.idPizza = idPizza;
    }

    @XmlTransient
    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @XmlTransient
    public boolean isVegetarienne()
    {
        return vegetarienne;
    }

    public void setVegetarienne(boolean vegetarienne)
    {
        this.vegetarienne = vegetarienne;
    }

    public boolean isPerso()
    {
        return perso;
    }

    @XmlTransient
    public void setPerso(boolean perso)
    {
        this.perso = perso;
    }

    @XmlTransient
    public double getPrix()
    {
        return prix;
    }

    public void setPrix(double prix)
    {
        this.prix = prix;
    }
    
    

    
}
